package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.WaresDao;
import dao.impl.IWaresDao;
import entity.News;
import entity.Wares;
import entity.WaresType;

public class IndexServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request,response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
//		String ttype1 = request.getParameter("ttype1");
//		String ttype2 = request.getParameter("ttype2");
//		String ttype3 = request.getParameter("ttype3");
//		String ttype4 = request.getParameter("ttype4");
		
		String ttype1 = "家用电器";
		String ttype2 = "书籍";
		String ttype3 = "手机数码";
		String ttype4 = "日用百货";
		
		WaresDao wd = new IWaresDao();
		List<WaresType> list1 = wd.FindType(ttype1);
		List<WaresType> list2 = wd.FindType(ttype2);
		List<WaresType> list3 = wd.FindType(ttype3);
		List<WaresType> list4 = wd.FindType(ttype4);
		List<Wares> list5 =wd.FindHot();
		List<Wares> list6 =wd.FindNew();
		List<News> list7 = wd.SelectNews(0);
		
		 request.setAttribute("list1", list1);
		 request.setAttribute("list2", list2);
		 request.setAttribute("list3", list3);
		 request.setAttribute("list4", list4);
		 request.setAttribute("list5", list5);
		 request.setAttribute("list6", list6);
		 request.setAttribute("list7", list7);
		request.getRequestDispatcher("index.jsp").forward(request, response);
		
		
		
		
		
		
	}

}
